<template>
    <base-breadcrumb>
        <a-spin :spinning="spinning">
            <a-card class="mb20">
                <titleName title="信息详情"></titleName>
                <a-form-model
                    :model="form"
                    :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                    :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
                >
                    <a-row :gutter="24">
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="所属分公司：">
                                <span>{{ form.branchComName }}</span>
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="所属项目：">
                                <span>{{ form.projectName }}</span>
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="8" :sm="8">
                            <a-form-model-item label="统计日期" prop="other">
                                <span>{{ form.createTime }}</span>
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                </a-form-model>
            </a-card>
            <!-- 安全教育 -->
            <a-card class="mb20">
                <titleName title="安全教育情况"></titleName>
                <table-template :columns="safetyEducation" :loaddata="form.safeEducationVOS"></table-template>
            </a-card>
            <!-- 安全关键会议 -->
            <a-card class="mb20">
                <titleName title="安全关键会议"></titleName>
                <table-template :columns="safetyMeeting" :loaddata="form.safetyMeets"></table-template>
            </a-card>
            <!-- 安全检查 -->
            <a-card class="mb20">
                <titleName title="安全检查"></titleName>
                <table-template :columns="securityCheck" :loaddata="form.safeCheckVOS"></table-template>
            </a-card>
            <!-- 安全隐患及整改情况 -->
            <a-card class="mb20">
                <titleName title="安全隐患及整改情况"></titleName>
                <table-template
                    :columns="safetyProblem"
                    :loaddata="form.safeCheckVOForStatusChangeList"
                ></table-template>
            </a-card>
            <!-- 安全技术交底情况 -->
            <a-card class="mb20">
                <titleName title="安全技术交底情况"></titleName>
                <table-template
                    :columns="securityTechnology"
                    :loaddata="form.safetyConfessRecordBusinessVOS"
                ></table-template>
            </a-card>
            <!-- 安全验收情况 -->
            <a-card class="mb20">
                <titleName title="安全验收情况"></titleName>
                <table-template
                    :columns="safetyAcceptance"
                    :loaddata="form.monthSafeRecordBusinessVOS"
                ></table-template>
            </a-card>
            <!-- 重大危险源旁站监督 -->
            <a-card class="mb20">
                <titleName title="重大危险源旁站监督"></titleName>
                <table-template :columns="hazards" :loaddata="form.sideStandBusinessVO"></table-template>
            </a-card>
            <!-- 危险作业审批情况 -->
            <a-card class="mb20">
                <titleName title="高风险作业许可审批情况"></titleName>
                <table-template :columns="jobApproval" :loaddata="form.dangerWorkVOList"></table-template>
            </a-card>
            <!-- 领导带班情况 -->
            <a-card class="mb20">
                <titleName title="领导带班情况"></titleName>
                <table-template :columns="leadShift" :loaddata="form.takeShiftProduceBusinessVOS"></table-template>
            </a-card>
            <!-- 其他 -->
            <a-card class="mb20">
                <titleName title="其他"></titleName>
                <BaseTextarea
                    disabled
                    placeholder="请输入"
                    v-model="form.other"
                    :autoSize="{ minRows: 20, maxRows: 25 }"
                    :maxLength="3000"
                ></BaseTextarea>
            </a-card>
            <div class="tool-btns page-btn-right-top">
                <BasePrintButton type="primary" :beforePrintFn="getRecordDetailPrintReq" />
                <a-button class="ml20" type="primary" @click="handleClose">关闭</a-button>
            </div>
        </a-spin>
    </base-breadcrumb>
</template>
<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 分公司
import { STable } from '@/components'
import TableTemplate from './table.vue'
import { getSecurityLogDetail,getRecordDetailPrint } from '@/api/safetySupervision/securityLog'
//安全教育
const safetyEducation = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '教育类型',
        dataIndex: 'educationType',
    },
    {
        title: '教育名称',
        dataIndex: 'meetingName',
    },
    {
        title: '教育负责人',
        dataIndex: 'educationResponsible',
    },
    {
        title: '受教育群体',
        dataIndex: 'mainParticipants',
    },
    {
        title: '人数',
        dataIndex: 'meetingCount',
    },
    {
        title: '教育内容',
        dataIndex: 'meetingExplains',
        width: '30%',
    },
]
//  <!-- 安全关键会议 -->
const safetyMeeting = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '会议名称',
        dataIndex: 'meetingName',
    },
    // {
    //     title: '主持人',
    //     dataIndex: 'educationResponsible',
    // },
    {
        title: '主持人',
        dataIndex: 'speaker',
    },
    {
        title: '主要参会者',
        dataIndex: 'meetingNames',
        scopedSlots: { customRender: 'meetingNames' },
    },
    {
        title: '人数',
        dataIndex: 'meetingCount',
    },
    {
        title: '开会时间',
        dataIndex: 'startTime',
    },
    {
        title: '会议说明',
        dataIndex: 'meetingExplains',
        width: '30%',
    },
]
// 安全检查情况
const securityCheck = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '检查类型',

        dataIndex: 'checkType',
    },
    {
        title: '检查人',
        ellipsis: true,
        dataIndex: 'employeeName',
    },
    {
        title: '检查区域',
        ellipsis: true,
        dataIndex: 'areaName',
    },
    {
        title: '检查结果',
        width: 100,
        dataIndex: 'checkResult',
    },

    {
        title: '检查时间',
        dataIndex: 'checkDate',
    },
    {
        title: '检查详情',
        dataIndex: 'checkDescribe',
    },
]
// 安全隐患及整改情况
const safetyProblem = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '隐患类型',
        dataIndex: 'probleamType',
    },
    {
        title: '隐患位置',
        dataIndex: 'areaName',
    },
    // {
    //     title: '是否属于十项零容忍',
    //     dataIndex: 'name',
    // },
    {
        title: '隐患整改责任人',
        dataIndex: 'duty',
    },
    {
        title: '验收人',
        dataIndex: 'reCheck',
    },
    {
        title: '隐患整改结果',
        dataIndex: 'status',
        width: '30%',
    },
]
// 安全技术交底情况
const securityTechnology = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '施工工序',
        dataIndex: 'wbsName',
    },
    {
        title: '交底名称',
        dataIndex: 'name',
    },
    {
        title: '交底人',
        dataIndex: 'creator',
    },
    {
        title: '被交底人',
        dataIndex: 'subName',
    },
    {
        title: '工种',
        dataIndex: 'workType',
    },

    {
        title: '交底要点',
        dataIndex: 'confessContent',
        width: '30%',
    },
]
// 安全验收情况
const safetyAcceptance = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '验收部位',
        dataIndex: 'acceptancePart',
    },
    {
        title: '验收负责人',
        dataIndex: 'acceptanceResEmployeeName',
    },
    {
        title: '验收类别',
        dataIndex: 'acceptanceTypeName',
    },
    {
        title: '验收内容',
        dataIndex: 'conclusion',
    },
    {
        title: '分包单位',
        dataIndex: 'subName',
    },

    {
        title: '验收结果',
        dataIndex: 'result',
        width: '30%',
    },
]
// 重大危险源旁站监督
const hazards = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '危险源名',
        dataIndex: 'planItemName',
    },
    {
        title: '作业单位',
        dataIndex: 'subContractName',
    },
    {
        title: '旁站时间',
        dataIndex: 'workerQuantity',
    },
    {
        title: '旁站人员',
        dataIndex: 'sideStandWorkerName',
    },
    {
        title: '旁站部位',
        dataIndex: 'sideStandPart',
        width: '30%',
    },
]
// 危险作业审批情况
const jobApproval = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '危险作业类型',
        dataIndex: 'type',
    },
    {
        title: '申请人',
        dataIndex: 'applyUserName',
    },

    {
        title: '分包单位',
        dataIndex: 'subName',
    },
    {
        title: '班组',
        dataIndex: 'team',
    },
    {
        title: '危险作业位置',
        dataIndex: 'area',
        width: '30%',
    },
    {
        title: '申请时间',
        dataIndex: 'applyDate',
    },
]
// 领导带班情况
const leadShift = [
    {
        title: '序号',
        dataIndex: 'sort',
        scopedSlots: { customRender: 'sort' },
    },
    {
        title: '带班领导',
        dataIndex: 'takeShiftName',
        width: '10%',
    },

    {
        title: '现场安全生产状况和管理情况',
        dataIndex: 'prodManageTypeNote',
        width: '40%',
    },
    {
        title: '下一步安全生产工作要求',
        dataIndex: 'nextWorkReq',
        ellipsis: true,
    },
]
export default {
    name:'a'+Date.now(),    components: {
        SelectSubCompany,
        SelectProject,
        TableTemplate,
    },
    data() {
        return {
            safetyEducation,
            safetyEducationData: [],
            safetyMeeting,
            safetyMeetingData: [],
            securityCheck,
            securityCheckData: [],
            safetyProblem,
            safetyProblemData: [],
            securityTechnology,
            securityTechnologyData: [],
            safetyAcceptance,
            safetyAcceptanceData: [],
            hazards,
            hazardsData: [],
            jobApproval,
            jobApprovalData: [],
            leadShift,
            leadShiftData: [],
            form: {},
            spinning: false,
        }
    },
    created() {
        this.id = this.$route.query.id
        this.getSecurityLogDetail()
    },
    methods: {
        getRecordDetailPrintReq() {
            const { id } = this.$route.query
            if (!id) return
            const params = {
                id,
            }
            return getRecordDetailPrint(params).then((res) => {
                console.log(res)
                return res[1].data.content
            })
        },
        async getSecurityLogDetail() {
            const { id } = this.$route.query
            if (!id) return
            const params = {
                id,
            }
            this.spinning = true
            const [err, res] = await getSecurityLogDetail(params)
            this.spinning = false
            if (!err) {
                this.form = {
                    ...this.form,
                    ...res.data,
                }

                console.log(this.form)
            }
        },
        handleClose() {
            this.$multiTab.close(this.$route.fullpath)
        },
    },
}
</script>
<style lang="less" scoped>
@deep: ~'>>>';
.tool-btns {
    display: flex;
    justify-content: flex-end;
    @{deep} .ant-btn + .ant-btn {
        margin-left: 12px;
    }
}
.row {
    display: flex;
    flex-direction: row;
}
</style>